﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using condortravel.operaciones.core;
using System.Collections;
using System.Web;
using condortravel.operaciones.common;

namespace condortravel.operaciones.persistence.ImpersonationBD
{
    public class ImpersonationBD
    {
        private Impersonation impersonation;
        private bool isImpersonate;

        public bool IsImpersonate
        {
            get { return isImpersonate; }
            set { isImpersonate = value; }
        }
        public Impersonation Impersonation
        {
            get {
                if (impersonation == null)
                    impersonation = new Impersonation();
                return impersonation; 
            }
            set { impersonation = value; }
        }
        //public bool IsImpersonate()
        //{
        //    return isImpersonate;
        //}
        public ImpersonationBD()
        { 
        
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dataModel"></param>
        public ImpersonationBD(String dataModel)
        {
            HttpContext ctx=HttpContext.Current;
            Hashtable table = null;
            try
            {
                if (dataModel.Equals("BDCondorTOperacionesImpersonate"))
                {

                    table = condortravel.operaciones.common.Util.readConnectioRegedit((String)ctx.Application[AppStatic.CONNECTION_REGEDIT_CONDORTOPERACIONES_IMPERSONATE]);

                }
               
            }
            catch (Exception exc) { }
            this.isImpersonate = (table.Count != 0);
            if (table.Count != 0)
            {
                Impersonation.Domain = table["Domain"].ToString();
                Impersonation.Password = table["Password"].ToString();
                Impersonation.User = table["User"].ToString();
            }

        }
    }
}
